
from QCommand import QCommand, CmdIDGen
# event
from EventDefine import event_QCMD_CHATMESSAGE

def DefaultMessageParser(self, message):
    ret = message
    return ret

class QCmdChatMessage(QCommand):
    CMDID = CmdIDGen()
    CMDNAME = "QCmdChatMessage"
    # message parser
    MessageParser = DefaultMessageParser

    def Send(self, message):
        QCommand.InputSend(self, memberID = QCommand.MyMemberID,param = message)

    def Handle(self, memberID, param):
        message = QCmdChatMessage.MessageParser(self, message = param)
        if message is not None:
            # raise event
            messenger.send(event_QCMD_CHATMESSAGE, [memberID, message])

    def MessageParserSet(self, fnc):
        QCmdChatMessage.MessageParser = fnc
